package figuras;

public class Reta {
	private Ponto pontoInicial;
	private Ponto pontoFinal;

	public Reta() {
		super();
	}
	
	public Reta(Ponto pontoInicial, Ponto pontoFinal) {
		super();
		this.pontoInicial = pontoInicial;
		this.pontoFinal = pontoFinal;
	}

	public Ponto getPontoInicial() {
		return pontoInicial;
	}

	public void setPontoInicial(Ponto pontoInicial) {
		this.pontoInicial = pontoInicial;
	}

	public Ponto getPontoFinal() {
		return pontoFinal;
	}

	public void setPontoFinal(Ponto pontoFinal) {
		this.pontoFinal = pontoFinal;
	}
	public double getTamanhoReta(){
		double piy = this.pontoInicial.getEixoY();
		double pfy = this.pontoFinal.getEixoY();
		double pix = this.pontoFinal.getEixoX();
		double pfx = this.pontoFinal.getEixoX();
		double tamanhoReta = 0;
		if( piy == pfy){
			tamanhoReta = this.getCalculoReta(pix, pfx);
		}else{
			tamanhoReta = this.getCalculoReta(pix, pfx);
		}
		return tamanhoReta;
	}
	public double getCalculoReta(double pix, double pfx){
		double tamanhoReta = 0;
		if(pix<pfx){
			tamanhoReta = pfx - pix;
		}else{
			tamanhoReta = pix - pfx;
		}
		return tamanhoReta;
	
	}
	@Override
	public String toString() {
		return "Reta pontoInicial=" + pontoInicial + "pontoFinal="
				+ pontoFinal ;
	}
	
	
}
